/**
 * Created by Administrator on 2016/6/13.
 */
var u_id = sessionStorage.u_id;
var session_id = sessionStorage.session_id;
var user_token = sessionStorage.user_token;
$(document).ready(function(){
        var $width = $(window).width();
        var $height   = $(window).height();
        var height = $("body>p").css("height");
        $(".mask").css({'height':$height,'width':$width});

});


//参考样例逻辑
$(document).ready(function(){
    $("#place select").css("display","none");
    $(".joinProcess2 section:nth-child(3) lable span").click(function(){
        $(".mask").css("display","inherit");
        $(".example").css("display","inherit");
    })
    $(".mask").click(function(){
        $(".mask").css("display","none");
        $(".example").css("display","none");
    });
    $(".example").click(function(){
        $(".mask").css("display","none");
        $(".example").css("display","none");
    })
});



//页面加载判断医生状态
$(document).ready(function(){
    $(document).ready(function()
    {
        $("#dtBox").DateTimePicker(
            {
                dateFormat:"yyyy-MM-dd"
            }
        );
    });


    $("input").trigger("focus");

        var u_id = sessionStorage.u_id;
        $.post(commonval+"/user_info",{
            u_id:u_id,
            user_token:user_token,
            device:"wap",
            session_id:session_id
        },function(data){
               if(data.status == 1){
                   var status = data.data.sh_status;
                   var fail_reason = data.data.fail_reason;
                   if(status == 1 || status == 2||status == 0){
                       $("#place span").css("left","2.67%");
                       $("#place span+span").css("left","29.67%");
                       $(".joinProcess1 #place").css("padding-left","0%");
                       $("#place span+span").css("color","#333333");
                       //$("#joinProcess1 .joinProcess2 .scroll").css("top","350");
                       //$(".joinProcess1 #lable span").css("display","none");
                       //$(".joinProcess1 #lable1 span").css("display","block");
                       $(".placeInfo").click(function(){
                           $("#place select").css("display","block");
                           $("#place span:first-child").css("left","-87%");
                           $("#place span+span").css("display","none");
                           $(".joinProcess1 #place").css("padding-left","20%");
                           $("#place").unbind("click");
                       })
                       $("#province").click(function(){
                           $("#city").css("display","block");
                       })
                       console.log(data.data.birthday);
                       $("#doctorName").val(data.data.name);
                       $("#txtBirthday").val(data.data.birthday);
                       $("#sexInput").val(data.data.sex);
                       $("#job").text(data.data.zhiwu);
                       //$("#province").val(data.data.province);
                       //$("#city").val(data.data.city);
                       $("#keshi").val(data.data.keshi);
                       sessionStorage.city = data.data.city;
                       $("#hospitalName").val(data.data.hospital_name);
                       $("#introduce").val(data.data.introduce);
                       $("#skilled").val(data.data.shan_chang);
                       $(".placeInfo").text(data.data.province+data.data.city);
                       $("#job").val(data.data.zhiwu);
                       $("#tel_price").val(data.data.tel_price);
                       $("#alipay").val(data.data.alipay);
                       var src = $(".upLoad section img").attr("src",data.data.live_pic);
                       var city1 = $("#city").val();
                       console.log(sessionStorage.city);
                   }

                   if(status==1){
                       $(".scroll").css("top","400px");
                       $(".joinProcess1").css("top","420px");
                       $("#lable3 span").css("top","447.5px");
                       $("body>p").css("display","block");
                       $("header p:nth-child(3)").css("display","block");
                       $("#joinProcess3Btn").attr("disabled","true");
                       var city = sessionStorage.city;
                       $('#city').change(function(){
                           city = $("#city").val()
                       });
                       $(".submit").click(function(){

                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $("#introduce").val();
                           var shan_chang = $("#skilled").val();
                           var keshi = $("#keshi").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           $.post(commonval+"/update_doctor",{
                               name:name,
                               sex:sex,
                               birthday:birthday,
                               province:province,
                               city:city,
                               zhiwu:zhiwu,
                               hospital_name:hospital_name,
                               introduce:introduce,
                               //meet_price:meet_price,
                               tel_price:tel_price,
                               u_id:u_id,
                               live_pic:live_pic,
                               shan_chang:shan_chang,
                               keshi:keshi,
                               user_token:user_token,
                               device:"wap",
                               session_id:session_id
                           },function(data){
                               if(data.status == 1){
                                   location.href="joinDoctorSuccess.html";
                               }else{
                                   createWindow(data.msg);
                                   function createWindow(msg) {
                                       var window =$("<section class='showMsg'></section>");
                                       var show = "<p>"+msg+"</p>";
                                       window.append(show);
                                       $("body").append(window);
                                       setTimeout("$('.showMsg').remove()",3000);
                                   }
                               }
                           })
                       })
                       $("header img").click(function(){
                           history.go(-1);
                       });
                       ;
                       $("#joinProcess1Btn").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var city = $("#city").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $(".joinProcess2 textarea").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           console.log(name,birthday,province,city,hospital_name,zhiwu);
                           $("section.joinProcess1").css("display","none");
                           $("section.joinProcess2").css("display","block");
                           $("header img").unbind();
                           $("header img").click(function(){;
                               $("section.joinProcess1").css("display","block");
                               $("section.joinProcess2").css("display","none");
                               $("header img").unbind();
                               $("header img").click(function(){
                                   history.go(-1);
                               });
                           });
                       })
                       var i;
                       $(function() {
                           var splik;

                           $('#file_upload').uploadifive({
                               'fileObjName': 'upload',
                               'auto'             : true,
                               'formData'         : {

                                   'user_token':user_token,
                                   'session_id':session_id,
                                   'device':"wap",
                                   'category':"live_pic"
                               },
                               'uploadLimit' : 1,
                               'simUploadLimit':1,
                               'fileType' : 'image/*',
                               'queueID'          : 'queue',
                               'uploadScript'     : commonval+'/uploadLiveImage',
                               'onUploadComplete' : function(file, data) {
                                   splik = JSON.parse(data);
                                   i = splik.data;
                                   $(".upLoad section img").attr("src",commonval+i);
                                   $(".joinProcess2 #queue a").css("top","-25px");
                               }
                           });
                       });
                       $("#joinProcess2Btn").click(function(){
                           var introduce = $(".joinProcess2 textarea").val();
                           var src = $(".upLoad img").attr("src");
                           console.log(src)
                           $("section.joinProcess2").css("display","none");
                           $("section.joinProcess3").css("display","block");

                           $("header img").unbind();
                           $("header img").click(function(){
                               $("section.joinProcess2").css("display","block");
                               $("section.joinProcess3").css("display","none");
                               $("header img").unbind();
                               $("header img").click(function(){
                                   $("section.joinProcess1").css("display","block");
                                   $("section.joinProcess2").css("display","none");
                                   $("header img").unbind();
                                   $("header img").click(function(){
                                       history.go(-1);
                                   });
                               });
                           });
                       });



                       ////提交医生申请
                       //$("#joinProcess3Btn").click(function(){
                       //    var name = $("#doctorName").val();
                       //    var birthday = $("#txtBirthday").val();
                       //    var sex = $("#sexInput").val();
                       //    var province = $("#province").val();
                       //    var zhiwu = $("#job").val();
                       //    var city = $("#city").val();
                       //    var hospital_name = $("#hospitalName").val();
                       //    var introduce = $(".joinProcess2 textarea").val();
                       //    //var meet_price = $("#meet_price").val();
                       //    var tel_price = $("#tel_price").val();
                       //    var src = $(".upLoad img").attr("src");
                       //    var live_pic = src.replace("http://dev.haotoufa.com",'');
                       //    var u_id = sessionStorage.u_id;
                       //    var alipay = $("#alipay").val();
                       //    if(tel_price==''||alipay==''){
                       //        createWindow("请填写信息完整");
                       //        function createWindow(msg) {
                       //            var window =$("<section class='showMsg'></section>");
                       //            var show = "<p>"+msg+"</p>";
                       //            window.append(show);
                       //            $("body").append(window);
                       //            setTimeout("$('.showMsg').remove()",3000);
                       //        }
                       //    }else{
                       //        $.post("http://dev.haotoufa.com/joinDoctor",{
                       //            name:name,
                       //            sex:sex,
                       //            birthday:birthday,
                       //            province:province,
                       //            city:city,
                       //            zhiwu:zhiwu,
                       //            hospital_name:hospital_name,
                       //            introduce:introduce,
                       //            //meet_price:meet_price,
                       //            tel_price:tel_price,
                       //            u_id:u_id,
                       //            live_pic:live_pic,
                       //            alipay:alipay,
                       //            token:token
                       //        },function(data){
                       //            if(data.status == 1){
                       //                location.href="joinDoctorSuccess.html";
                       //            }else{
                       //                createWindow(data.msg);
                       //                function createWindow(msg) {
                       //                    var window =$("<section class='showMsg'></section>");
                       //                    var show = "<p>"+msg+"</p>";
                       //                    window.append(show);
                       //                    $("body").append(window);
                       //                    setTimeout("$('.showMsg').remove()",3000);
                       //                }
                       //            }
                       //        })
                       //    }
                       //
                       //})
                   }else if(status==2){
                       $(".scroll").css("top","400px");
                       $(".joinProcess1").css("top","420px");
                       $("#lable3 span").css("top","447.5px");
                       $("body>p").css("display","block").addClass("failed").text("由于"+fail_reason+"医生资格未通过审核，如有疑问请致电850-32333");
                       $("header img").click(function(){
                           history.go(-1);
                       });
                       ;
                       var city = sessionStorage.city;
                       $('#city').change(function(){
                           city = $("#city").val()
                       });
                       $(".submit").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $("#introduce").val();
                           var shan_chang = $("#skilled").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var keshi = $("#keshi").val();
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           $.post(commonval+"/update_doctor",{
                               name:name,
                               sex:sex,
                               birthday:birthday,
                               province:province,
                               city:city,
                               zhiwu:zhiwu,
                               hospital_name:hospital_name,
                               introduce:introduce,
                               keshi:keshi,
                               //meet_price:meet_price,
                               shan_chang:shan_chang,
                               tel_price:tel_price,
                               u_id:u_id,
                               live_pic:live_pic,
                               user_token:user_token,
                               device:"wap",
                               session_id:session_id
                           },function(data){
                               if(data.status == 1){
                                   location.href="joinDoctorSuccess.html";
                               }else{
                                   createWindow(data.msg);
                                   function createWindow(msg) {
                                       var window =$("<section class='showMsg'></section>");
                                       var show = "<p>"+msg+"</p>";
                                       window.append(show);
                                       $("body").append(window);
                                       setTimeout("$('.showMsg').remove()",3000);
                                   }
                               }
                           })
                       })
                       $("#joinProcess1Btn").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var city = $("#city").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $(".joinProcess2 textarea").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           $("section.joinProcess1").css("display","none");
                           $("section.joinProcess2").css("display","block");
                           $("header img").unbind();
                           $("header img").click(function(){;
                               $("section.joinProcess1").css("display","block");
                               $("section.joinProcess2").css("display","none");
                               $("header img").unbind();
                               $("header img").click(function(){
                                   history.go(-1);
                               });
                           });
                       })
                       var i;
                       $(function() {
                           var splik;
                           $('#file_upload').uploadifive({
                               'fileObjName': 'upload',
                               'auto'             : true,
                               'formData'         : {
                                   'user_token':user_token,
                                   'session_id':session_id,
                                   'device':"wap",
                                   'category':"live_pic"
                               },
                               'uploadLimit' : 1,
                               'simUploadLimit':1,
                               'fileType' : 'image/*',
                               'queueID'          : 'queue',
                               'uploadScript'     :commonval+ '/uploadLiveImage',
                               'onUploadComplete' : function(file, data) {
                                   splik = JSON.parse(data);
                                   i = splik.data;
                                   $(".upLoad section img").attr("src",commonval+i);
                                   $(".joinProcess2 #queue a").css("top","-25px");
                               }
                           });
                       });
                       $("#joinProcess2Btn").click(function(){
                           var introduce = $(".joinProcess2 textarea").val();
                           var src = $(".upLoad img").attr("src");
                           $("section.joinProcess2").css("display","none");

                           $("section.joinProcess3").css("display","block");

                           $("header img").unbind();
                           $("header img").click(function(){
                               $("section.joinProcess2").css("display","block");
                               $("section.joinProcess3").css("display","none");
                               $("header img").unbind();
                               $("header img").click(function(){
                                   $("section.joinProcess1").css("display","block");
                                   $("section.joinProcess2").css("display","none");
                                   $("header img").unbind();
                                   $("header img").click(function(){
                                       history.go(-1);
                                   });
                               });
                           });

                       });



                       ////提交医生申请
                       //$("#joinProcess3Btn").click(function(){
                       //    var name = $("#doctorName").val();
                       //    var birthday = $("#txtBirthday").val();
                       //    var sex = $("#sexInput").val();
                       //    var province = $("#province").val();
                       //    var zhiwu = $("#job").val();
                       //    var city = $("#city").val();
                       //    var hospital_name = $("#hospitalName").val();
                       //    var introduce = $(".joinProcess2 textarea").val();
                       //    //var meet_price = $("#meet_price").val();
                       //    var tel_price = $("#tel_price").val();
                       //    var src = $(".upLoad img").attr("src");
                       //    var live_pic = src.replace("http://dev.haotoufa.com",'');
                       //    var u_id = sessionStorage.u_id;
                       //    var alipay = $("#alipay").val();
                       //    if(tel_price==''||alipay==''){
                       //        createWindow("请填写信息完整");
                       //        function createWindow(msg) {
                       //            var window =$("<section class='showMsg'></section>");
                       //            var show = "<p>"+msg+"</p>";
                       //            window.append(show);
                       //            $("body").append(window);
                       //            setTimeout("$('.showMsg').remove()",3000);
                       //        }
                       //    }else{
                       //        $.post("http://dev.haotoufa.com/joinDoctor",{
                       //            name:name,
                       //            sex:sex,
                       //            birthday:birthday,
                       //            province:province,
                       //            city:city,
                       //            zhiwu:zhiwu,
                       //            hospital_name:hospital_name,
                       //            introduce:introduce,
                       //            //meet_price:meet_price,
                       //            tel_price:tel_price,
                       //            u_id:u_id,
                       //            live_pic:live_pic,
                       //            alipay:alipay,
                       //            token:token
                       //        },function(data){
                       //            if(data.status == 1){
                       //                location.href="joinDoctorSuccess.html";
                       //            }else{
                       //                createWindow(data.msg);
                       //                function createWindow(msg) {
                       //                    var window =$("<section class='showMsg'></section>");
                       //                    var show = "<p>"+msg+"</p>";
                       //                    window.append(show);
                       //                    $("body").append(window);
                       //                    setTimeout("$('.showMsg').remove()",3000);
                       //                }
                       //            }
                       //        })
                       //    }
                       //
                       //})
                   }else if(status==0){

                       $(".scroll").css("top","450px");
                       $(".joinProcess1").css("top","470px");
                       $("#lable3 span").css("top","488.5px");
                       $("body>p").css("display","block").addClass("being").text("你的医生资格申请已在审核中，如有疑问请致电：850-89XXXX");
                       var city = sessionStorage.city;
                       $('#city').change(function(){
                           city = $("#city").val()
                       });
                       $("#joinProcess3Btn").attr("disabled","true");
                       $(".submit").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var city1 = $("#city").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $("#introduce").val();
                           var shan_chang = $("#skilled").val();
                           var keshi = $("#keshi").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var u_id = sessionStorage.u_id;
                           //var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           $.post(commonval+"/update_doctor",{
                               name:name,
                               sex:sex,
                               birthday:birthday,
                               province:province,
                               city:city,
                               zhiwu:zhiwu,
                               keshi:keshi,
                               hospital_name:hospital_name,
                               introduce:introduce,
                               //meet_price:meet_price,
                               tel_price:tel_price,
                               u_id:u_id,
                               live_pic:live_pic,
                               shan_chang:shan_chang,
                               user_token:user_token,
                               device:"wap",
                               session_id:session_id
                           },function(data){
                               if(data.status == 1){
                                   location.href="joinDoctorSuccess.html";
                               }else{
                                   createWindow(data.msg);
                                   function createWindow(msg) {
                                       var window =$("<section class='showMsg'></section>");
                                       var show = "<p>"+msg+"</p>";
                                       window.append(show);
                                       $("body").append(window);
                                       setTimeout("$('.showMsg').remove()",3000);
                                   }
                               }
                           })
                       })
                       $("header img").click(function(){
                           history.go(-1);
                       });
                       ;
                       $("#joinProcess1Btn").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var city = $("#city").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $(".joinProcess2 textarea").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           $("section.joinProcess1").css("display","none");

                           $("section.joinProcess2").css("display","block");

                           $("header img").unbind();
                           $("header img").click(function(){;
                               $("section.joinProcess1").css("display","block");
                               $("section.joinProcess2").css("display","none");
                               $("header img").unbind();
                               $("header img").click(function(){
                                   history.go(-1);
                               });
                           });


                       })
                       var i;
                       $(function() {
                           var splik;
                           $('#file_upload').uploadifive({
                               'fileObjName': 'upload',
                               'auto'             : true,
                               'formData'         : {
                                   'user_token':user_token,
                                   'session_id':session_id,
                                   'device':"wap",
                                   'category':"live_pic"
                               },
                               'uploadLimit' : 1,
                               'simUploadLimit':1,
                               'fileType' : 'image/*',
                               'queueID'          : 'queue',
                               'uploadScript'     : commonval+'/uploadLiveImage',
                               'onUploadComplete' : function(file, data) {
                                   splik = JSON.parse(data);
                                   i = splik.data;
                                   $(".upLoad section img").attr("src",commonval+i);
                                   $(".joinProcess2 #queue a").css("top","-25px");
                               }
                           });
                       });
                       $("#joinProcess2Btn").click(function(){
                           var introduce = $(".joinProcess2 textarea").val();
                           var src = $(".upLoad img").attr("src");
                           $("section.joinProcess2").css("display","none");

                           $("section.joinProcess3").css("display","block");

                           $("header img").unbind();
                           $("header img").click(function(){
                               $("section.joinProcess2").css("display","block");
                               $("section.joinProcess3").css("display","none");
                               $("header img").unbind();
                               $("header img").click(function(){
                                   $("section.joinProcess1").css("display","block");
                                   $("section.joinProcess2").css("display","none");
                                   $("header img").unbind();
                                   $("header img").click(function(){
                                       history.go(-1);
                                   });
                               });
                           });

                       });



                       ////提交医生申请
                       //$("#joinProcess3Btn").click(function(){
                       //    var name = $("#doctorName").val();
                       //    var birthday = $("#txtBirthday").val();
                       //    var sex = $("#sexInput").val();
                       //    var province = $("#province").val();
                       //    var zhiwu = $("#job").val();
                       //    var city = $("#city").val();
                       //    var hospital_name = $("#hospitalName").val();
                       //    var introduce = $(".joinProcess2 textarea").val();
                       //    //var meet_price = $("#meet_price").val();
                       //    var tel_price = $("#tel_price").val();
                       //    var src = $(".upLoad img").attr("src");
                       //    var live_pic = src.replace("http://dev.haotoufa.com",'');
                       //    var u_id = sessionStorage.u_id;
                       //    var alipay = $("#alipay").val();
                       //    if(tel_price==''||alipay==''){
                       //        createWindow("请填写信息完整");
                       //        function createWindow(msg) {
                       //            var window =$("<section class='showMsg'></section>");
                       //            var show = "<p>"+msg+"</p>";
                       //            window.append(show);
                       //            $("body").append(window);
                       //            setTimeout("$('.showMsg').remove()",3000);
                       //        }
                       //    }else{
                       //        $.post("http://dev.haotoufa.com/joinDoctor",{
                       //            name:name,
                       //            sex:sex,
                       //            birthday:birthday,
                       //            province:province,
                       //            city:city,
                       //            zhiwu:zhiwu,
                       //            hospital_name:hospital_name,
                       //            introduce:introduce,
                       //            //meet_price:meet_price,
                       //            tel_price:tel_price,
                       //            u_id:u_id,
                       //            live_pic:live_pic,
                       //            alipay:alipay,
                       //            token:token
                       //        },function(data){
                       //            if(data.status == 1){
                       //                location.href="joinDoctorSuccess.html";
                       //            }else{
                       //                createWindow(data.msg);
                       //                function createWindow(msg) {
                       //                    var window =$("<section class='showMsg'></section>");
                       //                    var show = "<p>"+msg+"</p>";
                       //                    window.append(show);
                       //                    $("body").append(window);
                       //                    setTimeout("$('.showMsg').remove()",3000);
                       //                }
                       //            }
                       //        })
                       //    }
                       //
                       //})
                   }else if(status==3){
                       $("#place span").css("left","2.67%");
                       $("#place span+span").css("left","29.67%");
                       $(".joinProcess1 #place").css("padding-left","0%");
                       $("#place span+span").css("color","#999999");
                       //$("#joinProcess1 .joinProcess2 .scroll").css("top","350");
                       //$(".joinProcess1 #lable span").css("display","none");
                       //$(".joinProcess1 #lable1 span").css("display","block");
                       $("#place").click(function(){
                           $("#place select").css("display","block");
                           $("#place span:first-child").css("left","-87%");
                           $("#place span+span").css("display","none");
                           $(".joinProcess1 #place").css("padding-left","20%");
                           $("#place").unbind("click");
                       })
                       $("#province").click(function(){
                           $("#city").css("display","block");
                       })
                       $(".joinProcess1").css("top","351px");
                       $(".scroll").css("top","331px");
                       $(".joinProcess04").css("display","none");
                       $(".joinProcess01").css("display","block");
                       $("header img").click(function(){
                           history.go(-1);
                       });
                       ;
                       $("#joinProcess1Btn").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var city = $("#city").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $("#introduce").val();
                           var shan_chang = $("#skilled").val();
                           var keshi = $("#keshi").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           console.log(name==''||birthday==''||province==''||city==''||hospital_name==''||zhiwu=='');
                           if(name==''||birthday==''||province==''||city==''||hospital_name==''||zhiwu==''||keshi==''){
                               createWindow("请填写信息完整");
                               return false;
                               function createWindow(msg) {
                                   var window =$("<section class='showMsg'></section>");
                                   var show = "<p>"+msg+"</p>";
                                   window.append(show);
                                   $("body").append(window);
                                   setTimeout("$('.showMsg').remove()",3000);
                               }
                           }else{
                               $("section.joinProcess1").css("display","none");
                               $("section.joinProcess01").css("display","none");
                               $("section.joinProcess2").css("display","block");
                               $("section.joinProcess02").css("display","block");
                               $("header img").unbind();
                               $("header img").click(function(){;
                                   $("section.joinProcess1").css("display","block");
                                   $("section.joinProcess01").css("display","block");
                                   $("section.joinProcess2").css("display","none");
                                   $("section.joinProcess02").css("display","none");
                                   $("header img").unbind();
                                   $("header img").click(function(){
                                       history.go(-1);
                                   });
                               });

                           }

                       })
                       var i;
                       $(function() {
                           var splik;
                           $('#file_upload').uploadifive({
                               'fileObjName': 'upload',
                               'auto'             : true,
                               'formData'         : {
                                   'user_token':user_token,
                                   'session_id':session_id,
                                   'device':"wap",
                                   'category':"live_pic"
                               },
                               'uploadLimit' : 1,
                               'simUploadLimit':1,
                               'fileType' : 'image/*',
                               'queueID'          : 'queue',
                               'uploadScript'     : commonval+'/uploadLiveImage',
                               'onUploadComplete' : function(file, data) {
                                   splik = JSON.parse(data);
                                   i = splik.data;
                                   $(".upLoad section img").attr("src",commonval+i);
                                   $(".joinProcess2 #queue a").css("top","-25px");
                               }
                           });
                       });
                       $("#joinProcess2Btn").click(function(){
                           var introduce = $(".joinProcess2 textarea").val();
                           var src = $(".upLoad img").attr("src");
                           console.log(src)
                           $("section.joinProcess2").css("display","none");
                           $("section.joinProcess02").css("display","none");
                           $("section.joinProcess3").css("display","block");
                           $("section.joinProcess03").css("display","block");
                           $("header img").unbind();
                           $("header img").click(function(){
                               $("section.joinProcess2").css("display","block");
                               $("section.joinProcess02").css("display","block");
                               $("section.joinProcess3").css("display","none");
                               $("section.joinProcess03").css("display","none")
                               $("header img").unbind();
                               $("header img").click(function(){
                                   $("section.joinProcess1").css("display","block");
                                   $("section.joinProcess01").css("display","block");
                                   $("section.joinProcess2").css("display","none");
                                   $("section.joinProcess02").css("display","none");
                                   $("header img").unbind();
                                   $("header img").click(function(){
                                       history.go(-1);
                                   });
                               });
                           });
                       });



                       //提交医生申请
                       $("#joinProcess3Btn").click(function(){
                           var name = $("#doctorName").val();
                           var birthday = $("#txtBirthday").val();
                           var sex = $("#sexInput").val();
                           var province = $("#province").val();
                           var zhiwu = $("#job").val();
                           var city = $("#city").val();
                           var hospital_name = $("#hospitalName").val();
                           var introduce = $("#introduce").val();
                           var shan_chang = $("#skilled").val();
                           var keshi = $("#keshi").val();
                           //var meet_price = $("#meet_price").val();
                           var tel_price = $("#tel_price").val();
                           var src = $(".upLoad section img").attr("src");
                           var live_pic = src.substr(length);
                           var u_id = sessionStorage.u_id;
                           var alipay = $("#alipay").val();
                           if(tel_price==''){
                               createWindow("请填写信息完整");
                               function createWindow(msg) {
                                   var window =$("<section class='showMsg'></section>");
                                   var show = "<p>"+msg+"</p>";
                                   window.append(show);
                                   $("body").append(window);
                                   setTimeout("$('.showMsg').remove()",3000);
                               }
                           }else{
                               $.post(commonval+"/joinDoctor",{
                                   name:name,
                                   sex:sex,
                                   birthday:birthday,
                                   province:province,
                                   city:city,
                                   keshi:keshi,
                                   zhiwu:zhiwu,
                                   hospital_name:hospital_name,
                                   introduce:introduce,
                                   //meet_price:meet_price,
                                   tel_price:tel_price,
                                   u_id:u_id,
                                   shan_chang:shan_chang,
                                   live_pic:live_pic,
                                   //alipay:alipay,
                                   user_token:user_token,
                                   device:"wap",
                                   session_id:session_id
                               },function(data){
                                   if(data.status == 1){
                                       location.href="joinDoctorSuccess.html";
                                   }else{
                                       createWindow(data.msg);
                                       function createWindow(msg) {
                                           var window =$("<section class='showMsg'></section>");
                                           var show = "<p>"+msg+"</p>";
                                           window.append(show);
                                           $("body").append(window);
                                           setTimeout("$('.showMsg').remove()",3000);
                                       }
                                   }
                               })
                           }

                       })
                   }
                   $("header p:nth-child(3)").click(function(){
                       $(".editInfo").toggle();
                       $(".mask").toggle();
                       $("header p:nth-child(3)").unbind();
                   })
                   $(".editInfo p:nth-child(2) span").click(function(){
                       $(".editInfo").toggle();
                       $(".mask").toggle();
                   })
                   $(".editInfo p:nth-child(2) span:nth-child(2)").click(function(){
                       $("header p:nth-child(3)").text("取消编辑");
                       $("header p:nth-child(3)").click(function(){
                           $("#joinProcess3Btn").attr("disabled",true);
                           $("header p:nth-child(3)").text("编辑");
                           $("header p:nth-child(3)").unbind();
                           $("header p:nth-child(3)").click(function(){
                               $(".editInfo").toggle();
                               $(".mask").toggle();
                               $("header p:nth-child(3)").unbind();
                           })
                           $("#joinProcess1Btn").css("width","100%")
                           $("#joinProcess2Btn").css("width","95%");
                           $("#joinProcess1Btn+button").css("display","none");
                           $("#joinProcess2Btn+button").css("display","none");
                       })
                       $("#joinProcess3Btn").removeAttr("disabled");
                       $("#joinProcess1Btn").css("width","48.7%")
                       $("#joinProcess2Btn").css("width","46.7%");
                       $("#joinProcess1Btn+button").css("display","inline-block")
                       $("#joinProcess2Btn+button").css("display","inline-block")
                   })
               }else{
                   if(data.msg=="非法请求"){
                       createWindow("登录失效，正在跳转至登录界面");
                       function createWindow(msg) {
                           var window =$("<section class='showMsg'></section>");
                           var show = "<p>"+msg+"</p>";
                           window.append(show);
                           $("body").append(window);
                           setTimeout("$('.showMsg').remove()",3000);
                       }
                       setTimeout(function(){location.href="register.html?jump=4"},4000);
                   }

               }
        })
})
//固定按钮位置

$(document).ready(function(){
    var $width = $(window).width();
    var height = window.innerHeight;
    $(".mask").css({"width":$width,"height":height});
    $("#joinProcess1Btn").parent("section").css("top",height-135);
    $("#joinProcess2Btn").parent("section").css("top",height-135);
    $("#joinProcess3Btn").parent("section").css("top",height-135);
    $(".jobTitle").css("top",(height-400)/2-100);
    $(".editInfo").css("top",(height-360)/2-100);
});
//性别切换
$(document).ready(function(){
    $(".sex a").click(function(){
        $(".sex a").removeClass("active");
        $(this).addClass("active");
    })
    $(".sex a:first-child").click(function(){
        if($(".boy").hasClass("active")){
            $(".boy").children("img").attr("src","../images/icon_man_elect.png")
        }else{
            $(".boy").children("img").attr("src","../images/icon_man.png")
        }
        if($(".girl").hasClass("active")){
            $(".girl").children("img").attr("src","../images/icon_woman_elect.png")
        }else{
            $(".girl").children("img").attr("src","../images/icon_woman.png")
        }
        $(this).parent().parent().children("input").val("1");
    })
    $(".sex a:last-child").click(function(){
        if($(".boy").hasClass("active")){
            $(".boy").children("img").attr("src","../images/icon_man_elect.png")
        }else{
            $(".boy").children("img").attr("src","../images/icon_man.png")
        }
        if($(".girl").hasClass("active")){
            $(".girl").children("img").attr("src","../images/icon_woman_elect.png")
        }else{
            $(".girl").children("img").attr("src","../images/icon_woman.png")
        }
        $(this).parent().parent().children("input").val("2");
    })
});

//地址下拉框
$(document).ready(function(){
    $('#place').cxSelect({
        url: '../cityData.min.json',
        selects: ['province', 'city']
    });
});

//职务相关逻辑
$(document).ready(function(){
    $(".joinProcess1 section:nth-child(7)").click(function(){
        $(".mask").css("display","block");
        $(".jobTitle").css("display","block");
    })
    $(".mask").click(function(){
        $(".mask").css("display","none");
        $(".jobTitle").css("display","none");
    })
    $(".jobTitle p").click(function(){
        $(".mask").css("display","none");
        $(".jobTitle").css("display","none");
        var zhiwu = $(this).text();
        $(".joinProcess1 section:nth-child(7) input").val(zhiwu);
        $("#jobContent").text(zhiwu);
    })
});

//顶部返回上一步
//input动画
//$(document).ready(function(){
//    $('.joinProcess1 input').focus(function(){
//        $(this).parent("section").children("span").first().animate({"top":"20px","font-size":"0.7rem"});
//        $(this).animate({"margin-top":"-25px"});
//    }).blur(function(){
//        if($(this).val()==""){
//            $(this).parent("section").children("span").first().animate({"top":"55px","font-size":"1rem"});
//            $(this).animate({"margin-top":"-50px"});
//        }
//    })
//    $('.joinProcess1 section:nth-child(4) input').focus(function(){
//        $(this).parent("section").children("span").first().animate({"top":"10px","font-size":"0.7rem"});
//        $(this).animate({"margin-top":"-50px"});
//    }).blur(function(){
//        if($(this).val()==""){
//            $(this).parent("section").children("span").first().animate({"top":"35px","font-size":"1rem"});
//            $(this).animate({"margin-top":"-50px"});
//        }
//    })
//    $('.joinProcess1 section:nth-child(6) input').focus(function(){
//        $(this).parent("section").children("span").first().animate({"top":"10px","font-size":"0.7rem"});
//        $(this).animate({"margin-top":"-50px"});
//    }).blur(function(){
//        if($(this).val()==""){
//            $(this).parent("section").children("span").first().animate({"top":"35px","font-size":"1rem"});
//            $(this).animate({"margin-top":"-60px"});
//        }
//    })
//    //$('.joinProcess1 section:nth-child(7)').click(function(){
//    //    $(this).parent("section").children("span").first().animate({"top":"10px","font-size":"0.7rem"});
//    //    $(this).animate({"margin-top":"-50px"});
//    //}).blur(function(){
//    //    if($(this).val()==""){
//    //        $(this).parent("section").children("span").first().animate({"top":"35px","font-size":"1rem"});
//    //        $(this).animate({"margin-top":"-50px"});
//    //    }
//    //})
//    $('.joinProcess1 #place select').focus(function(){
//        $(this).parent("section").children("span").first().animate({"top":"15px","font-size":"0.7rem"});
//    }).blur(function(){
//        if($(this).val()==""){
//            $(this).parent("section").children("span").first().animate({"top":"35px","font-size":"1rem"});
//        }
//    })
//});


//表单传递
//顶部返回上一步

//$("document").ready(function() {
//    $("header img").click(function(){
//        history.go(-1);
//    });
//    $("#joinProcess1Btn").click(function(){
//        $("section.joinProcess1").css("display","none");
//        $("section.joinProcess2").css("display","block");
//        $("header img").unbind();
//        $("header img").click(function(){;
//            $("section.joinProcess1").css("display","block");
//            $("section.joinProcess2").css("display","none");
//            $("header img").unbind();
//            $("header img").click(function(){
//                history.go(-1);
//            });
//        });
//    })
//    $("#joinProcess2Btn").click(function(){
//        $("section.joinProcess2").css("display","none");
//        $("section.joinProcess3").css("display","block");
//        $("header img").unbind();
//        $("header img").click(function(){
//            $("section.joinProcess2").css("display","block");
//            $("section.joinProcess3").css("display","none");
//            $("header img").unbind();
//            $("header img").click(function(){
//                $("section.joinProcess1").css("display","block");
//                $("section.joinProcess2").css("display","none");
//            });
//        });
//    });
//});
//joinProcess1表单验证
$("document").ready(function(){
    ////获得焦点错误信息删除
    $("#joinProcess1 input").focus(function(){
        var $name=$(this).attr("name");
        var emID ="#"+$name+"-error";
        $(emID).css("display","none");
    })
    //全部验证通过注册按钮解锁
    $("#joinProcess1 input").blur(function(){
        var emSuccess = $("em.success");
        if(emSuccess.length==5){
            $("#joinProcess1Btn").removeAttr("disabled");
        }
    })

    //注册表单验证规则
    $("#joinProcess1").validate({
        onkeyup:false,
        rules : {
            name:{
                required : true,
            },
            birthday:{
                required : true
            },
            province:{
                required : true
            },
            city : {
                required : true
            },
            hospital_name:{
            required : true
        }
        },
        messages : {
            name : {
                required : "姓名不能为空",
            },
            birthday:{
                required : "请选择出生日期",
            },
            province:{
                required : "地址不能为空"
            },
            city : {
                required : "城市/区不能为空",
            },
            hospital_name: {
                required : "医院名称不能为空",
            }
        },
        errorElement: "em",
        success: function(lable) {
            lable.text(" ")
                .addClass("success");
        }
        //em元素放置位置
        //errorPlacement: function(error, element) {
        //    error.appendTo( element.parent() );
        //}
    });
})
//joinProcess2上传图片
$("document").ready(function(){
    $(".joinProcess2 .upLoad img").click(function(){
        $("#file_upload+input").click();
    })
    $(".upLoad a").html("上传图片");
});


//joinProcess2表单验证
$("document").ready(function(){
    ////获得焦点错误信息删除
    $("#joinProcess1 input").focus(function(){
        var $name=$(this).attr("name");
        var emID ="#"+$name+"-error";
        $(emID).css("display","none");
    })
    //全部验证通过注册按钮解锁
    $("#joinProcess1 input").blur(function(){
        var emSuccess = $("em.success");
        if(emSuccess.length==5){
            $("#joinProcess1Btn").removeAttr("disabled");
        }
    })

    //注册表单验证规则
    $("#joinProcess1").validate({
        onkeyup:false,
        rules : {
            doctorName:{
                required : true,
            },
            birthday:{
                required : true
            },
            province:{
                required : true
            },
            city : {
                required : true
            },
            hospitalName:{
                required : true
            }
        },
        messages : {
            doctorName : {
                required : "姓名不能为空",
            },
            birthday:{
                required : "请选择出生日期",
            },
            province:{
                required : "地址不能为空"
            },
            city : {
                required : "城市/区不能为空",
            },
            hospitalName: {
                required : "医院名称不能为空",
            }
        },
        errorElement: "em",
        success: function(lable) {
            lable.text(" ")
                .addClass("success");
        }
    });
})

//$(function () {
//    var opt = {
//        theme: "android-ics light",
//        display: 'modal', //显示方式
//        lang: "zh",
//        setText: '确定', //确认按钮名称
//        cancelText: "取消",
//        dateFormat: 'yyyy-mm-dd', //返回结果格式化为年月格式
//        dateOrder: 'yyyymmdd', //面板中日期排列格式
//        onBeforeShow: function (inst) {
//            //  console.info( inst.settings.wheels);
//        },
//        headerText: function (valueText) { //自定义弹出框头部格式
//            //  console.info(valueText);
//            array = valueText.split('-');
//            return array[0] + "年" + array[1] + "月" + array[2] + "日";
//        }
//    };
//
//    $("#txtBirthday").mobiscroll().date(opt);
//
//});



////参考示例
//$("document").ready(function(){
//    $(".upLoad span").click(function(){
//
//    })
//});


